package com.steamedfish.auctioncloudprocess.task;

import org.quartz.*;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Configuration;

import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Configuration
public class TaskScheduler {

    @Autowired
    private Scheduler scheduler;

    public void triggerStartAuctionAlertTask(String id, Date date) throws SchedulerException {
        JobDetail jobDetail = StartAuctionAlertTask.getJobDetail(id);
        Trigger simpleTrigger = StartAuctionAlertTask.getTrigger(date);
//        scheduler.clear();
        scheduler.scheduleJob(jobDetail, simpleTrigger);
        scheduler.start();
    }


    public void triggerAuctionResultAdTask(String id, Date date) throws SchedulerException {
        JobDetail jobDetail = AuctionResultAdTask.getJobDetail(id);
        Trigger simpleTrigger = AuctionResultAdTask.getTrigger(date);
//        scheduler.clear();
        scheduler.scheduleJob(jobDetail, simpleTrigger);
        scheduler.start();
    }

}